package com.tian.web.admin.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.annotation.Resource;
import javax.persistence.FetchType;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.tian.core.action.BaseAction;
import com.tian.core.entity.Action;
import com.tian.core.entity.Actioncolumn;
import com.tian.core.entity.Group;
import com.tian.core.entity.Master;
import com.tian.core.entity.Mastergroup;
import com.tian.core.entity.Ztree;

@Namespace("/admin")
@Results( {  
	@Result(type = "dispatcher", name = "success", location = "/pages/admin/menu.jsp"),
})
public class MenuAction extends BaseAction {

	private static final long serialVersionUID = 1L;

//	@Resource
//	private ActioncolumnService actcolService;
	
	private List<Ztree> ztrees;
	
	@Override
	public String execute() throws Exception {
		//List<Actioncolumn> list = new ArrayList<Actioncolumn>();
		
		Master user = (Master)ServletActionContext.getRequest().getSession().getAttribute("user");
		//需要取消懒加载，改为fetch = FetchType.EAGER
		Set<Mastergroup> setMG = user.getMastergroups();
		for(Mastergroup mg : setMG){
			Group g = mg.getGroup();
			Set<Ztree> setZtrees = g.getZtrees();
			for(Ztree node : setZtrees){
				//ztrees.add(node);
			}
		}
		
		return SUCCESS;
	}

	public List<Ztree> getZtrees() {
		return ztrees;
	}

	public void setZtrees(List<Ztree> ztrees) {
		this.ztrees = ztrees;
	}
	
	
}
